package com.abing.starry.config;

import com.abing.starry.config.intercepter.RenewalInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @Author CaptainBing
 * @Date 2024/8/16 18:42
 * @Description
 */
@Configuration
@RequiredArgsConstructor
public class WebMvcConfig implements WebMvcConfigurer {

    private final RenewalInterceptor renewalInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> excludePathList = new ArrayList<>();
        List<String> aboutUser = Arrays.asList("/user/register", "/user/captcha/**", "/user/login", "/user/login/captcha");
        List<String> aboutDoc = Arrays.asList("/doc.html", "/webjars/**", "/v3/api-docs/**", "/swagger-ui.html");
        List<String> aboutSimulator = Collections.singletonList("/simulator/**");
        List<String> aboutApiCache = Collections.singletonList("/interface/_init");
        excludePathList.addAll(aboutDoc);
        excludePathList.addAll(aboutUser);
        excludePathList.addAll(aboutSimulator);
        excludePathList.addAll(aboutApiCache);

//        registry.addInterceptor(renewalInterceptor)
//                .addPathPatterns("/**")
//                .excludePathPatterns(excludePathList);

    }
}
